package com.ufo.store.management.widget.view;

import android.content.Context;
import android.widget.TextView;

import com.github.mikephil.charting.components.MarkerView;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.utils.MPPointF;
import com.ufo.store.management.R;

/**
 *  作者：taoli on 2017/6/19 0019 15:35
 *  
 */
public class ChartMarkerView extends MarkerView {
    private TextView tvContent;

    public ChartMarkerView(Context context, int layoutResource) {
        super(context, layoutResource);
        tvContent = findViewById(R.id.tvContent);
    }

    @Override
    public void refreshContent(Entry e, Highlight highlight) {
        String str = "";
        float x = e.getX();
        if( x > 12 ){
            str = "下午" + (int)( x - 12 ) + ":00 ";
        }else{
            str = "上午" + (int)( x ) + ":00 ";
        }
        tvContent.setText(str + String.valueOf((int)e.getY()) + "笔");
        super.refreshContent(e, highlight);
    }

    @Override
    public MPPointF getOffset() {
        return new MPPointF(-(getWidth() / 2), -getHeight());
    }
}
